package com.example.drive.net.callback

import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.util.Log
import okhttp3.Response

/**
 * 返回位图
 */
abstract class BitmapCallback : NetworkCallback<Bitmap> {
    companion object {
        private const val TAG = "BitmapCallback"
    }

    override fun parseNetworkResponse(response: Response): Bitmap? {
        return kotlin.runCatching {
            val inputStream = response.body.byteStream()
            BitmapFactory.decodeStream(inputStream)
        }.getOrElse {
            Log.e(TAG, "parseNetworkResponse error:$it")
            null
        }
    }
}